home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / gnushogi.lha / gnushogi-1.1 / src / uxdsp.c < prev    next >
C/C++ Source or Header  |  1993-04-16  |  21KB  |  1,002 lines

  1. /*
  2.  * uxdsp.c - ALPHA interface for GNU SHOGI
  3.  *
  4.  * Copyright (c) 1993 Matthias Mutz
  5.  *
  6.  * GNU SHOGI is based on GNU CHESS
  7.  *
  8.  * Copyright (c) 1988,1989,1990 John Stanback
  9.  * Copyright (c) 1992 Free Software Foundation
  10.  *
  11.  * This file is part of GNU SHOGI.
  12.  *
  13.  * GNU Shogi is free software; you can redistribute it and/or modify
  14.  * it under the terms of the GNU General Public License as published by
  15.  * the Free Software Foundation; either version 1, or (at your option)
  16.  * any later version.
  17.  *
  18.  * GNU Shogi is distributed in the hope that it will be useful,
  19.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  * GNU General Public License for more details.
  22.  *
  23.  * You should have received a copy of the GNU General Public License
  24.  * along with GNU Shogi; see the file COPYING.  If not, write to
  25.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  */
  27.  
  28.  
  29. #include <ctype.h>
  30. #include <signal.h>
  31.  
  32. #if defined MSDOS
  33. #include <dos.h>
  34. #include <conio.h>
  35. #include <stdlib.h>
  36. #include <string.h>
  37. #include <time.h>
  38.  
  39. #define ESC 0x1B
  40. #define refresh() fflush(stdout)
  41.  
  42. static void param (short n);
  43.  
  44. #elif defined THINK_C
  45.  
  46. #include <stdio.h>
  47. #include <console.h>
  48.  
  49. #define clear() cgotoxy(1,1,stdout),ccleos(stdout)
  50. #define refresh() fflush(stdout)
  51.  
  52. #else
  53.  
  54. #include <sys/param.h>
  55. #include <sys/types.h>
  56. #include <sys/file.h>
  57. #include <curses.h>
  58.  
  59. #endif /* MSDOS */
  60.  
  61. int mycnt1, mycnt2;
  62.  
  63. #include "gnushogi.h"
  64.  
  65. extern short int pscore[2];
  66.  
  67. #define TAB (58)
  68.  
  69. #define VIR_C(s)  ((flag.reverse) ? 8-column(s) : column(s))
  70. #define VIR_R(s)  ((flag.reverse) ? 8-row(s) : row(s))
  71.  
  72. unsigned short int MV[MAXDEPTH];
  73. int MSCORE;
  74. char *DRAW;
  75. extern char mvstr[4][6];
  76.  
  77. void TerminateSearch (int), Die (int);
  78.  
  79. void
  80. Initialize (void)
  81. {
  82.   signal (SIGINT, Die);
  83. #if !defined MSDOS && !defined THINK_C
  84.   signal (SIGQUIT, Die);
  85.   initscr ();
  86.   crmode ();
  87. #else
  88.   mycnt1 = mycnt2 = 0;
  89. #endif /* MSDOS */
  90. }
  91.  
  92. void
  93. ExitChess (void)
  94. {
  95.   ListGame ();
  96.   gotoXY (1, 24);
  97. #if !defined MSDOS && !defined THINK_C
  98.   refresh();
  99.   nocrmode ();
  100.   endwin ();
  101. #endif /* MSDOS */
  102.   exit (0);
  103. }
  104.  
  105. void
  106. Die (int Sig)
  107. {
  108.   char s[80];
  109.  
  110.   signal (SIGINT, SIG_IGN);
  111. #if defined MSDOS || defined THINK_C
  112.   Sig++;            /* shut up the compiler */
  113. #else
  114.   signal (SIGQUIT, SIG_IGN);
  115. #endif /* MSDOS */
  116.   ShowMessage (CP[31]);        /*Abort?*/
  117.   scanz ("%s", s);
  118.   if (strcmp (s, CP[210]) == 0)    /*yes*/
  119.     ExitChess ();
  120.   signal (SIGINT, Die);
  121. #if !defined MSDOS && !defined THINK_C
  122.   signal (SIGQUIT, Die);
  123. #endif /* MSDOS */
  124. }
  125.  
  126. void
  127. TerminateSearch (int Sig)
  128. {
  129.   signal (SIGINT, SIG_IGN);
  130. #if defined MSDOS || defined THINK_C
  131.   Sig++;            /* shut up the compiler */
  132. #else
  133.   signal (SIGQUIT, SIG_IGN);
  134. #endif /* MSDOS */
  135.   if (!flag.timeout)
  136.     flag.musttimeout = true;
  137.   flag.bothsides = false;
  138.   signal (SIGINT, Die);
  139. #if !defined MSDOS && !defined THINK_C
  140.   signal (SIGQUIT, Die);
  141. #endif /* MSDOS */
  142. }
  143. void
  144. ShowLine (short unsigned int *bstline)
  145. {
  146. }
  147.  
  148. void
  149. help (void)
  150. {
  151.   ClrScreen ();
  152.   /*printz ("CHESS command summary\n");*/
  153.   printz (CP[40]);
  154.   printz ("----------------------------------------------------------------\n");
  155.   /*printz ("7g7f      move from 7g to 7f      quit      Exit Chess\n");*/
  156.   printz (CP[158]);
  157.   /*printz ("S6h       move silver to 6h       beep      turn %s\n", (flag.beep) ? "off" : "on");*/
  158.   printz (CP[86], (flag.beep) ? CP[92] : CP[93]);
  159.   /*printz ("2d2c+     move to 2c and promote\n");*/
  160.   printz (CP[128], (flag.material) ? CP[92] : CP[93]);
  161.   /*printz ("P*5e      drop a pawn to 5e       easy      turn %s\n", (flag.easy) ? "off" : "on");*/
  162.   printz (CP[173], (flag.easy) ? CP[92] : CP[93]);
  163.   /*printz ("                                  hash      turn %s\n", (flag.hash) ? "off" : "on");*/
  164.   printz (CP[174], (flag.hash) ? CP[92] : CP[93]);
  165.   /*printz ("bd        redraw board            reverse   board display\n");*/
  166.   printz (CP[130]);
  167.   /*printz ("list      game to shogi.lst       book      turn %s used %d of %d\n", (Book) ? "off" : "on", book
  168. count, booksize);*/
  169.   printz (CP[170], (Book) ? CP[92] : CP[93], bookcount, BOOKSIZE);
  170.   /*printz ("undo      undo last ply           remove    take back a move\n");*/
  171.   printz (CP[200]);
  172.   /*printz ("edit      edit board              force     enter game moves\n");*/
  173.   printz (CP[153]);
  174.   /*printz ("switch    sides with computer     both      computer match\n");*/
  175.   printz (CP[194]);
  176.   /*printz ("black     computer plays black    white     computer plays white\n");*/
  177.   printz (CP[202]);
  178.   /*printz ("depth     set search depth        clock     set time control\n");*/
  179.   printz (CP[149]);
  180.   /*printz ("hint      suggest a move         post      turn %s principle variation\n", (flag.post) ? "off" :
  181. "on");*/
  182.   printz (CP[177], (flag.post) ? CP[92] : CP[93]);
  183.   /*printz ("save      game to file            get       game from file\n");*/
  184.   printz (CP[188]);
  185.   /*printz ("random    randomize play          new       start new game\n");*/
  186.   printz (CP[181]);
  187.   gotoXY (10, 20);
  188.   printz (CP[47], ColorStr[computer]);
  189.   gotoXY (10, 21);
  190.   printz (CP[97], ColorStr[opponent]);
  191.   gotoXY (10, 22);
  192.   printz (CP[79], MaxResponseTime/100);
  193.   gotoXY (10, 23);
  194.   printz (CP[59], (flag.easy) ? CP[93] : CP[92]);
  195.   gotoXY (25, 23);
  196.   printz (CP[231], (flag.tsume) ? CP[93] : CP[92]);
  197.   gotoXY (40, 20);
  198.   printz (CP[52], MaxSearchDepth);
  199.   gotoXY (40, 21);
  200.   printz (CP[100], (dither) ? CP[93] : CP[92]);
  201.   gotoXY (40, 22);
  202.   printz (CP[112], (flag.hash) ? CP[93] : CP[92]);
  203.   gotoXY (40, 23);
  204.   printz (CP[73]);
  205.   gotoXY (10, 24);
  206.   printz (CP[110], (TCflag) ? CP[93] : CP[92],
  207.       TimeControl.moves[black], TimeControl.clock[black] / 100, OperatorTime, MaxSearchDepth);
  208.   refresh ();
  209. #ifdef BOGUS
  210.   fflush (stdin); /*what is this supposed to do??*/
  211. #endif /*BOGUS*/
  212.   getchar ();
  213.   ClrScreen ();
  214.   UpdateDisplay (0, 0, 1, 0);
  215. }
  216.     
  217.  
  218. static const short x0[2] = {54, 2};
  219. static const short y0[2] = {20, 4};
  220.  
  221.  
  222. static
  223. void 
  224. UpdateCatched ()
  225.  
  226. {
  227.   short side;
  228.   for ( side = black; side <= white; side++ )
  229.     { 
  230.     short x, y, piece, cside, k;
  231.     cside = flag.reverse ? (side ^ 1) : side;
  232.         x = x0[cside];
  233.         y = y0[cside];
  234.     k = 0;
  235.         for ( piece = pawn; piece <= king; piece++ )
  236.           { short n;
  237.         if ( n = Captured[side][piece] )
  238.           { gotoXY(x,y); 
  239.             printz("%i%c",n,pxx[piece]);
  240.             if ( cside == black ) y--; else y++;
  241.           }
  242.         else
  243.         k++;
  244.       };
  245.     while ( k )
  246.       { k--;
  247.         gotoXY(x,y);
  248.         printz("  ");
  249.         if ( cside == black ) y--; else y++;
  250.       }
  251.    }
  252.   refresh();
  253. }
  254.  
  255.  
  256. void
  257. EditBoard (void)
  258.  
  259. /*
  260.  * Set up a board position. Pieces are entered by typing the piece followed
  261.  * by the location. For example, N3f will place a knight on square 3f.
  262.  * P* will put a pawn to the captured pieces.
  263.  */
  264.  
  265. {
  266.   short a, r, c, sq, i;
  267.   char s[80];
  268.  
  269.   flag.regularstart = true;
  270.   Book = BOOKFAIL;
  271.   ClrScreen ();
  272.   UpdateDisplay (0, 0, 1, 0);
  273.   gotoXY (TAB, 3);
  274.   printz (CP[29]);
  275.   gotoXY (TAB, 4);
  276.   printz (CP[28]);
  277.   gotoXY (TAB, 5);
  278.   printz (CP[136]);
  279.   gotoXY (TAB, 7);
  280.   printz (CP[64]);
  281.   a = black;
  282.   do
  283.     {
  284.       gotoXY (TAB, 6);
  285.       printz (CP[60], ColorStr[a]);    /*Editing %s*/
  286.       gotoXY (TAB + 24, 7);
  287.       ClrEoln ();
  288.       scanz ("%s", s);
  289.       if (s[0] == CP[28][0])    /*#*/
  290.     {
  291.       for (sq = 0; sq < NO_SQUARES; sq++)
  292.         {
  293.           board[sq] = no_piece;
  294.           color[sq] = neutral;
  295.           DrawPiece (sq);
  296.         }
  297.       ClearCaptured ();
  298.           UpdateCatched ();
  299.     }
  300.       if (s[0] == CP[136][0])    /*c*/
  301.     a = otherside[a];
  302.       if (s[1] == '*')
  303.     {
  304.       for (i = NO_PIECES; i > no_piece; i--)
  305.         if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
  306.           break;
  307.       Captured[a][unpromoted[i]]++;
  308.           UpdateCatched ();
  309.       c = -1;
  310.     }
  311.       else
  312.     {
  313.             c = '9' - s[1];
  314.             r = 'i' - s[2];
  315.     }
  316.       if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS))
  317.     {
  318.       sq = locn (r, c);
  319.       for (i = NO_PIECES; i > no_piece; i--)
  320.         if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
  321.           break;
  322.       if ( s[3] == '+' )
  323.         i = promoted[i];
  324.           else
  325.             i = unpromoted[i];
  326.       board[sq] = i;
  327.       color[sq] = ((board[sq] == no_piece) ? neutral : a);
  328.       DrawPiece (sq);
  329.     }
  330.   } while (s[0] != CP[29][0]);    /*.*/
  331.  
  332.   for (sq = 0; sq < NO_SQUARES; sq++)
  333.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  334.   GameCnt = 0;
  335.   Game50 = 1;
  336.   ZeroRPT ();
  337.   Sdepth = 0;
  338.   InitializeStats ();
  339.   ClrScreen ();
  340.   UpdateDisplay (0, 0, 1, 0);
  341. }
  342.  
  343. void
  344. ShowPlayers (void)
  345. {
  346.   gotoXY (5, ((flag.reverse) ? 23 : 2));
  347.   printz ("%s", (computer == white) ? CP[218] : CP[74]);
  348.   gotoXY (5, ((flag.reverse) ? 2 : 23));
  349.   printz ("%s", (computer == black) ? CP[218] : CP[74]);
  350. }
  351.  
  352. void
  353. ShowDepth (char ch)
  354. {
  355.   gotoXY (TAB, 4);
  356.   printz (CP[53], Sdepth, ch);    /*Depth= %d%c*/
  357.   ClrEoln ();
  358. }
  359.  
  360. void
  361. ShowScore (short score)
  362. {
  363.   gotoXY (TAB, 5);
  364.   printz (CP[104], score);
  365.   ClrEoln ();
  366. }
  367.  
  368. void
  369. ShowMessage (char *s)
  370. {
  371.   gotoXY (TAB, 6);
  372.   printz ("%s", s);
  373.   ClrEoln ();
  374. }
  375.  
  376. void
  377. ClearMessage (void)
  378. {
  379.   gotoXY (TAB, 6);
  380.   ClrEoln ();
  381. }
  382.  
  383. void
  384. ShowCurrentMove (short int pnt, short int f, short int t)
  385. {
  386.   algbr (f, t, false);
  387.   gotoXY (TAB, 7);
  388.   printz ("(%2d) %5s ", pnt, mvstr[0]);
  389. }
  390.  
  391. void
  392. ShowHeader (void)
  393. {
  394.   gotoXY (TAB, 2);
  395.   printz (CP[69]);
  396. }
  397.  
  398. void
  399. ShowSidetoMove (void)
  400. {
  401.   gotoXY (TAB, 14);
  402.   printz ("%2d:   %s", 1 + GameCnt / 2, ColorStr[player]);
  403.   ClrEoln ();
  404. }
  405.  
  406. void
  407. ShowPrompt (void)
  408. {
  409.   gotoXY (TAB, 19);
  410.   printz (CP[121]);        /*Your movwe is?*/
  411.   ClrEoln ();
  412. }
  413.  
  414. void
  415. ShowNodeCnt (long int NodeCnt)
  416. {
  417.   gotoXY (TAB, 21);
  418.   printz (CP[90], NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0);
  419.   ClrEoln ();
  420. }
  421.  
  422. void
  423. ShowResults (short int score, short unsigned int *bstline, char ch)
  424. {
  425.   unsigned char d, ply;
  426.  
  427.   if (flag.post)
  428.     {
  429.       ShowDepth (ch);
  430.       ShowScore (score);
  431.       d = 7;
  432.       for (ply = 1; bstline[ply] > 0; ply++)
  433.     {
  434.       if (ply % 4 == 1)
  435.         {
  436.           gotoXY (TAB, ++d);
  437.           ClrEoln ();
  438.         }
  439.       algbr ((short) bstline[ply] >> 8, (short) bstline[ply] & 0xFF, false);
  440.       printz ("%5s ", mvstr[0]);
  441.     }
  442.       ClrEoln ();
  443.       while (d < 13)
  444.     {
  445.       gotoXY (TAB, ++d);
  446.       ClrEoln ();
  447.     }
  448.     }
  449. }
  450.  
  451. void
  452. SearchStartStuff (short int side)
  453. {
  454.   short i;
  455.  
  456.   signal (SIGINT, TerminateSearch);
  457. #if defined MSDOS || defined THINK_C
  458.   side++;            /* shut up the compiler */
  459. #else
  460.   signal (SIGQUIT, TerminateSearch);
  461. #endif /* MSDOS */
  462.   for (i = 4; i < 14; i++)
  463.     {
  464.       gotoXY (TAB, i);
  465.       ClrEoln ();
  466.     }
  467. }
  468.  
  469. void
  470. OutputMove (void)
  471. {
  472.  
  473.   UpdateDisplay (root->f, root->t, 0, (short) root->flags);
  474.   gotoXY (TAB, 17);
  475.   if(flag.illegal){printz(CP[225]);return;}
  476.   printz (CP[84], mvstr[0]);    /*My move is %s*/
  477.   if (flag.beep)
  478.     putchar (7);
  479.   ClrEoln ();
  480.  
  481.   gotoXY (TAB, 23);
  482.   if (root->flags & draw)
  483.     printz (CP[58]);
  484.   else if (root->score == -(SCORE_LIMIT+999))
  485.     printz (CP[95]);
  486.   else if (root->score == SCORE_LIMIT+998)
  487.     printz (CP[44]);
  488. #ifdef VERYBUGGY
  489.   else if (root->score < -SCORE_LIMIT)
  490.     printz (CP[96]);
  491.   else if (root->score > SCORE_LIMIT)
  492.     printz (CP[45]);
  493. #endif /*VERYBUGGY*/
  494.   ClrEoln ();
  495.   if (flag.post)
  496.     {
  497.       register short h, l, t;
  498.  
  499.       h = TREE;
  500.       l = 0;
  501.       t = TREE >> 1;
  502.       while (l != t)
  503.     {
  504.       if (Tree[t].f || Tree[t].t)
  505.         l = t;
  506.       else
  507.         h = t;
  508.       t = (l + h) >> 1;
  509.     }
  510.  
  511.       ShowNodeCnt (NodeCnt);
  512.       gotoXY (TAB, 22);
  513.       printz (CP[81], t);    /*Max Tree=*/
  514.       ClrEoln ();
  515.     }
  516.   ShowSidetoMove ();
  517. }
  518.  
  519. void
  520. UpdateClocks (void)
  521. {
  522.   short m, s;
  523.  
  524.   m = (short) (et / 6000);
  525.   s = (short) (et - 6000 * (long) m) / 100;
  526.   if (TCflag)
  527.     {
  528.       m = (short) ((TimeControl.clock[player] - et) / 6000);
  529.       s = (short) ((TimeControl.clock[player] - et - 6000 * (long) m) / 100);
  530.     }
  531.   if (m < 0)
  532.     m = 0;
  533.   if (s < 0)
  534.     s = 0;
  535.   if (player == black)
  536.     gotoXY (20, (flag.reverse) ? 2 : 23);
  537.   else
  538.     gotoXY (20, (flag.reverse) ? 23 : 2);
  539.   printz ("%d:%02d   ", m, s);
  540.   if (flag.post)
  541.     ShowNodeCnt (NodeCnt);
  542.   refresh ();
  543. }
  544.  
  545. void
  546. gotoXY (short int x, short int y)
  547. {
  548. #if defined MSDOS
  549.   putchar (ESC);
  550.   putchar ('[');
  551.   param (y);
  552.   putchar (';');
  553.   param (x);
  554.   putchar ('H');
  555. #elif defined THINK_C
  556.   cgotoxy (x, y, stdout);
  557. #else
  558.   move (y - 1, x - 1);
  559. #endif /* MSDOS */
  560. }
  561.  
  562. void
  563. ClrScreen (void)
  564. {
  565. #ifdef MSDOS
  566.   putchar (ESC);
  567.   putchar ('[');
  568.   putchar ('2');
  569.   putchar ('J');
  570. #else
  571.   clear ();
  572. #endif /* MSDOS */
  573.   refresh ();
  574. }
  575.  
  576. void
  577. ClrEoln (void)
  578. {
  579. #ifdef MSDOS
  580.   putchar (ESC);
  581.   putchar ('[');
  582.   putchar ('K');
  583. #elif defined THINK_C
  584.   ccleol (stdout);
  585. #else
  586.   clrtoeol ();
  587. #endif /* MSDOS */
  588.   refresh ();
  589. }
  590.  
  591. #ifdef MSDOS
  592. void
  593. param (short n)
  594. {
  595.   if (n >= 10)
  596.     {
  597.       register short d, q;
  598.  
  599.       q = n / 10;
  600.       d = n % 10;
  601.       putchar (q + '0');
  602.       putchar (d + '0');
  603.     }
  604.   else
  605.     putchar (n + '0');
  606. }
  607.  
  608. #endif /* MSDOS */
  609.  
  610. void
  611. DrawPiece (short int sq)
  612. {
  613.   register char x, y;
  614.  
  615.   char piece,l,r,p; 
  616.  
  617. #if defined(MSDOS) && !defined(SEVENBIT)
  618.   if (color[sq] == white)
  619.     x = '7';            /* print WHITE boldface, */
  620.   else
  621.     x = '1';            /* print BLACK inverted     */
  622.   piece = board[sq];
  623.   if ( is_promoted[piece] ) {
  624.     p = '+'; y = pxx[unpromoted[piece]];
  625.   } else {
  626.     p = ' '; y = pxx[piece];
  627.   };
  628.   gotoXY (8 + 5 * VIR_C (sq), 4 + 2 * (8 - VIR_R (sq)));
  629.   printz ("\033[%cm%c%c\033[0m", x, p, y);
  630. #else
  631.   if ( color[sq]==neutral ) 
  632.     l = r = ' ';
  633.   else if ( flag.reverse ^ (color[sq]==black) ) {
  634.     l = '/'; r = '\\';
  635.   } else {
  636.     l = '\\', r = '/';
  637.   }; 
  638.   piece = board[sq];
  639.   if ( is_promoted[piece] ) {
  640.     p = '+'; y = pxx[unpromoted[piece]];
  641.   } else {
  642.     p = ' '; y = pxx[piece];
  643.   };
  644.   gotoXY (8 + 5 * VIR_C (sq), 4 + 2 * (8 - VIR_R (sq)));
  645.   printz ("%c%c%c%c", l, p, y, r);
  646. #endif
  647. }
  648.  
  649. void
  650. ShowPostnValue (short int sq)
  651.  
  652. /*
  653.  * must have called ExaminePosition() first
  654.  */
  655.  
  656. {
  657.   short score;
  658.  
  659.   gotoXY (4 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  660.   score = ScorePosition (color[sq]);
  661.   if (color[sq] != neutral)
  662.     printz ("%3d ", svalue[sq]);
  663.   else
  664.     printz ("   ");
  665. }
  666.  
  667. void
  668. ShowPostnValues (void)
  669. {
  670.   short sq, score;
  671.  
  672.   ExaminePosition ();
  673.   for (sq = 0; sq < NO_SQUARES; sq++)
  674.     ShowPostnValue (sq);
  675.   score = ScorePosition (opponent);
  676.   gotoXY (TAB, 5);
  677.   printz (CP[103], score, 
  678.             mtl[computer], pscore[computer], GameType[computer],
  679.             mtl[opponent], pscore[opponent], GameType[opponent]);
  680.  
  681.   ClrEoln ();
  682. }
  683.  
  684.  
  685. void
  686. UpdateDisplay (short int f, short int t, short int redraw, short int isspec)
  687. {
  688.   short i, sq, z;
  689.  
  690.   if (redraw)
  691.     {
  692.       ShowHeader ();
  693.       ShowPlayers ();
  694.  
  695.       i = 2;
  696.       gotoXY (3, ++i);
  697. #if defined(MSDOS) && !defined(SEVENBIT)
  698.       printz ("\332\304\304\304\304\302\304\304\304\304\302\304\304\304\304" \
  699.         "\302\304\304\304\304\302\304\304\304\304\302\304\304\304\304" \
  700.           "\302\304\304\304\304\302\304\304\304\304\277");
  701. #else            
  702.       printz ("    +----+----+----+----+----+----+----+----+----+");
  703. #endif /* MSDOS && !SEVENBIT */
  704.       while (i < 20)
  705.     {
  706.       gotoXY (1, ++i);
  707.       if (flag.reverse)
  708.         z = (i / 2) - 1;
  709.       else
  710.         z = 11 - ((i+1) / 2);
  711. #if defined(MSDOS) && !defined(SEVENBIT)
  712.       printz ("%d \263    \263    \263    \263    \263    \263    " \
  713.           "\263    \263    \263", z);
  714. #else
  715.       printz ("    %c |    |    |    |    |    |    |    |    |    |", 'a'+9-z);
  716. #endif /* MSDOS && !SEVENBIT */
  717.       gotoXY (3, ++i);
  718.       if (i < 20)
  719. #if defined(MSDOS) && !defined(SEVENBIT)
  720.         printz ("\303\304\304\304\304\305\304\304\304\304\305\304\304" \
  721.             "\304\304\305\304\304\304\304\305\304\304\304\304\305" \
  722.             "\304\304\304\304\305\304\304\304\304\305\304\304\304" \
  723.             "\304\264");
  724. #else              
  725.         printz ("    +----+----+----+----+----+----+----+----+----+");
  726. #endif /* MSDOS && !SEVENBIT */
  727.     }
  728. #if defined(MSDOS) && !defined(SEVENBIT)
  729.       printz ("\300\304\304\304\304\301\304\304\304\304\301\304\304\304\304" \
  730.         "\301\304\304\304\304\301\304\304\304\304\301\304\304\304\304" \
  731.           "\301\304\304\304\304\301\304\304\304\304\331");
  732. #else 
  733.       printz ("    +----+----+----+----+----+----+----+----+----+");
  734. #endif /* MSDOS && !SEVENBIT */
  735.       gotoXY (3, 22);
  736.       printz("    ");
  737.       if (flag.reverse)
  738.     printz (CP[16]);
  739.       else
  740.     printz (CP[15]);
  741.       for (sq = 0; sq < NO_SQUARES; sq++)
  742.     DrawPiece (sq);
  743.     }
  744.   else /* not redraw */
  745.     {
  746.       if ( f < NO_SQUARES )
  747.         DrawPiece (f);
  748.       DrawPiece (t & 0x7f);
  749.     }
  750.   if ( (isspec & capture) || (isspec & dropmask) || redraw )
  751.     { short side;
  752.       for ( side = black; side <= white; side++ )
  753.           { short x, y, piece, cside, k;
  754.             cside = flag.reverse ? (side ^ 1) : side;
  755.             x = x0[cside];
  756.             y = y0[cside];
  757.             k = 0;
  758.             for ( piece = pawn; piece <= king; piece++ )
  759.               { short n;
  760.             if ( n = Captured[side][piece] )
  761.               { gotoXY(x,y); 
  762.                 printz("%i%c",n,pxx[piece]);
  763.                 if ( cside == black ) y--; else y++;
  764.               }
  765.             else
  766.                k++;
  767.           };
  768.         while ( k )
  769.           { k--;
  770.         gotoXY(x,y);
  771.         printz("  ");
  772.             if ( cside == black ) y--; else y++;
  773.           }
  774.           }
  775.     }
  776.   refresh ();
  777. }
  778.  
  779. extern char *InPtr;
  780. void
  781. skip ()
  782. {
  783.   while (*InPtr != ' ')
  784.     InPtr++;
  785.   while (*InPtr == ' ')
  786.     InPtr++;
  787. }
  788. void
  789. skipb ()
  790. {
  791.   while (*InPtr == ' ')
  792.     InPtr++;
  793. }
  794.  
  795. void
  796. ChangeAlphaWindow (void)
  797. {
  798.   ShowMessage (CP[114]);
  799.   scanz ("%hd", &WAwindow);
  800.   ShowMessage (CP[34]);
  801.   scanz ("%hd", &BAwindow);
  802. }
  803.  
  804. void
  805. ChangeBetaWindow (void)
  806. {
  807.   ShowMessage (CP[115]);
  808.   scanz ("%hd", &WBwindow);
  809.   ShowMessage (CP[35]);
  810.   scanz ("%hd", &BBwindow);
  811. }
  812.  
  813. void
  814. GiveHint (void)
  815. {
  816.   char s[40];
  817.   if (hint)
  818.     {
  819.       algbr ((short) (hint >> 8), (short) (hint & 0xFF), false);
  820.       strcpy (s, CP[198]);    /*try*/
  821.       strcat (s, mvstr[0]);
  822.       ShowMessage (s);
  823.     }
  824.   else
  825.     ShowMessage (CP[223]);
  826. }
  827.  
  828. void
  829. ChangeHashDepth (void)
  830. {
  831.   ShowMessage (CP[163]);
  832.   scanz ("%hd", &HashDepth);
  833.   ShowMessage (CP[82]);
  834.   scanz ("%hd", &HashMoveLimit);
  835. }
  836.  
  837. void
  838. ChangeSearchDepth (void)
  839. {
  840.   ShowMessage (CP[150]);
  841.   scanz ("%hd", &MaxSearchDepth);
  842.   TCflag = !(MaxSearchDepth > 0);
  843. }
  844.  
  845. void
  846. SetContempt (void)
  847. {
  848.   ShowMessage (CP[142]);
  849.   scanz ("%hd", &contempt);
  850. }
  851.  
  852. void
  853. ChangeXwindow (void)
  854. {
  855.   ShowMessage (CP[208]);
  856.   scanz ("%hd", &xwndw);
  857. }
  858.  
  859. void
  860. SelectLevel (char *sx)
  861. {
  862.   int item;
  863.  
  864.   ClrScreen ();
  865.   gotoXY (32, 2);
  866.   printz (CP[41]);
  867.   gotoXY (20, 4);
  868.   printz (CP[18]);
  869.   gotoXY (20, 5);
  870.   printz (CP[19]);
  871.   gotoXY (20, 6);
  872.   printz (CP[20]);
  873.   gotoXY (20, 7);
  874.   printz (CP[21]);
  875.   gotoXY (20, 8);
  876.   printz (CP[22]);
  877.   gotoXY (20, 9);
  878.   printz (CP[23]);
  879.   gotoXY (20, 10);
  880.   printz (CP[24]);
  881.   gotoXY (20, 11);
  882.   printz (CP[25]);
  883.   gotoXY (20, 12);
  884.   printz (CP[26]);
  885.   gotoXY (20, 13);
  886.   printz (CP[27]);
  887.  
  888.   OperatorTime = 0;
  889.   TCmoves = 60;
  890.   TCminutes = 5;
  891.   TCseconds = 0;
  892.  
  893.   gotoXY (20, 17);
  894.   printz (CP[62]);
  895.   refresh ();
  896.   scanz ("%d", &item);
  897.   switch (item)
  898.     {
  899.     case 1:
  900.       TCmoves = 60;
  901.       TCminutes = 5;
  902.       break;
  903.     case 2:
  904.       TCmoves = 60;
  905.       TCminutes = 15;
  906.       break;
  907.     case 3:
  908.       TCmoves = 60;
  909.       TCminutes = 30;
  910.       break;
  911.     case 4:
  912.       TCmoves = 40;
  913.       TCminutes = 30;
  914.       break;
  915.     case 5:
  916.       TCmoves = 40;
  917.       TCminutes = 60;
  918.       break;
  919.     case 6:
  920.       TCmoves = 40;
  921.       TCminutes = 120;
  922.       break;
  923.     case 7:
  924.       TCmoves = 40;
  925.       TCminutes = 240;
  926.       break;
  927.     case 8:
  928.       TCmoves = 1;
  929.       TCminutes = 15;
  930.       break;
  931.     case 9:
  932.       TCmoves = 1;
  933.       TCminutes = 60;
  934.       break;
  935.     case 10:
  936.       TCmoves = 1;
  937.       TCminutes = 600;
  938.       break;
  939.     }
  940.  
  941.   TCflag = (TCmoves > 0);
  942.  
  943.   TimeControl.clock[black] = TimeControl.clock[white] = 0; 
  944.  
  945.   SetTimeControl ();
  946.   ClrScreen ();
  947.   UpdateDisplay (0, 0, 1, 0);
  948. }
  949.  
  950. void
  951. DoDebug (void)
  952. {
  953.   short c, p, sq, tp, tc, tsq, score;
  954.   char s[40];
  955.  
  956.   ExaminePosition ();
  957.   ShowMessage (CP[65]);
  958.   scanz ("%s", s);
  959.   c = neutral;
  960.   if (s[0] == CP[9][0] || s[0] == CP[9][1])    /*b B*/
  961.     c = black;
  962.   if (s[0] == CP[9][2] || s[0] == CP[9][3])    /*w W*/
  963.     c = white;
  964.   for (p = king; p > no_piece; p--)
  965.     if ((s[1] == pxx[p]) || (s[1] == qxx[p]))
  966.       break;
  967.   for (sq = 0; sq < NO_SQUARES; sq++)
  968.     {
  969.       tp = board[sq];
  970.       tc = color[sq];
  971.       board[sq] = p;
  972.       color[sq] = c;
  973.       tsq = PieceList[c][1];
  974.       PieceList[c][1] = sq;
  975.       ShowPostnValue (sq);
  976.       PieceList[c][1] = tsq;
  977.       board[sq] = tp;
  978.       color[sq] = tc;
  979.     }
  980.   score = ScorePosition (opponent);
  981.   gotoXY (TAB, 5);
  982.   printz (CP[103], score, 
  983.              mtl[computer], pscore[computer], GameType[computer],
  984.              mtl[opponent], pscore[opponent], GameType[opponent]);
  985.  
  986.   ClrEoln ();
  987. }
  988.  
  989. void
  990. DoTable (short table[NO_SQUARES])
  991. {
  992.   short  sq;
  993.   ExaminePosition ();
  994.   for (sq=0;sq<NO_SQUARES;sq++) {
  995.     gotoXY (4 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  996.     printz ("%3d ", table[sq]);
  997.   }
  998.  
  999.  
  1000.  
  1001.